﻿<UserControl x:Class="Hisaab.Windows.Client.View.TransactionEditorView"
	  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	  xmlns:my="clr-namespace:CustomControls;assembly=MultiComboBox"
	  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      mc:Ignorable="d" d:DesignHeight="259" d:DesignWidth="849">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150" />
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="10*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="34" />
            <RowDefinition Height="138*" />
        </Grid.RowDefinitions>

        <Label Grid.Column="0" Grid.Row="0" Content="Title" Style="{DynamicResource EditorLabel}" />
        <TextBox Grid.Column="2" Grid.Row="0" Text="{Binding Path=SelectedTransaction.Title, Mode=TwoWay}" Style="{DynamicResource EditorTextBox}" />

        <Label Grid.Column="0" Grid.Row="1" Content="Details" Style="{DynamicResource EditorLabel}" />
        <TextBox Grid.Column="2" Grid.Row="1" Text="{Binding Path=SelectedTransaction.Details, Mode=TwoWay}" Style="{DynamicResource EditorTextBox}" />

        <Label Grid.Column="0" Grid.Row="2" Content="Amount" Style="{DynamicResource EditorLabel}" />
        <TextBox Grid.Column="2" Grid.Row="2" Text="{Binding Path=SelectedTransaction.Amount, StringFormat='{}{0:C}', Mode=TwoWay}" Style="{DynamicResource EditorTextBox}" />

        <Label Grid.Column="0" Grid.Row="3" Content="Account" Style="{DynamicResource EditorLabel}" />
        <ComboBox Grid.Column="2" Grid.Row="3"
            ItemsSource="{Binding Path=Accounts}"
            SelectedValuePath="AccountId"
            SelectedValue="{Binding Path=SelectedTransaction.Account, Mode=TwoWay}" Style="{DynamicResource EditorComboBox}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Label Grid.Column="0" Grid.Row="4" Content="Type" Style="{DynamicResource EditorLabel}" />
        <ComboBox Grid.Column="2" Grid.Row="4"
            ItemsSource="{Binding Path=TransactionTypes}"
            SelectedValuePath="Key"
            SelectedValue="{Binding Path=SelectedTransaction.TransactionType, Mode=TwoWay}" Style="{DynamicResource EditorComboBox}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Value}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Label Grid.Column="0" Grid.Row="5" Content="Date" Style="{DynamicResource EditorLabel}" />
        <DatePicker Grid.Column="2" Grid.Row="5" SelectedDate="{Binding Path=SelectedTransaction.Date, Mode=TwoWay}" Style="{DynamicResource EditorDatePicker}" />

        <Label Grid.Column="0" Grid.Row="6" Content="Tags" Style="{DynamicResource EditorLabel}" />
        <my:MultiComboBox  Grid.Column="2" Grid.Row="6"
                               IsCreateNewEnabled="False"
                               SelectedItems="{Binding Path=SelectedTransaction.Tags, Mode=TwoWay}"
                               ItemsSource="{Binding Path=Tags}"
                               DisplayMemberPath="Name"
                               SelectedValuePath="TagId"
                               SelectionMode="Multiple" Style="{DynamicResource EditorMultiComboBox}">
            <my:MultiComboBox.DisplaySeparator>
                <TextBlock Text="," />
            </my:MultiComboBox.DisplaySeparator>
        </my:MultiComboBox>

        <Label Grid.Column="0" Grid.Row="7" Content="Account" Style="{DynamicResource EditorLabel}" Visibility="{Binding SelectedTransaction.IsTransferTransaction, Converter={StaticResource VisibilityConverter}}" />
        <ComboBox Grid.Column="2" Grid.Row="7"
        ItemsSource="{Binding Path=Accounts}"
        SelectedValuePath="AccountId"
        SelectedValue="{Binding Path=SelectedTransaction.LinkedTransactionAccount, Mode=TwoWay}" Style="{DynamicResource EditorComboBox}"
        Visibility="{Binding SelectedTransaction.IsTransferTransaction, Converter={StaticResource VisibilityConverter}}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Label Grid.Column="0" Grid.Row="8" Content="Date" Style="{DynamicResource EditorLabel}" Visibility="{Binding SelectedTransaction.IsTransferTransaction, Converter={StaticResource VisibilityConverter}}" />
        <DatePicker Grid.Column="2" Grid.Row="8"
                    SelectedDate="{Binding Path=SelectedTransaction.LinkedTransactionDate, Mode=TwoWay}"
                    Style="{DynamicResource EditorDatePicker}"
                    Visibility="{Binding SelectedTransaction.IsTransferTransaction, Converter={StaticResource VisibilityConverter}}" />
    </Grid>
</UserControl>